package com.xmzs.sd.controller;

import com.xmzs.common.core.domain.R;
import com.xmzs.sd.domain.SdModel;
import com.xmzs.sd.service.StableDiffusionService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * sd绘画控制器
 *
 * @author: wangle
 * @date: 2023/7/6
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/sd")
public class StableDiffusionController {

    private final StableDiffusionService stableDiffusionClient;


    /**
     * 获取sd模型信息
     *
     * @param
     * @return R<List < SdModel>>
     * @Date 2023/7/15
     **/
    @GetMapping("/getModels")
    public R<List<SdModel>> getModels() {
        return R.ok(stableDiffusionClient.modelList());
    }

    /**
     * 文生图
     *
     * @param prompt
     * @param modeName
     * @return R<List < String>>
     * @Date 2023/7/14
     **/
    @PostMapping("/text2img")
    public R<List<String>> text2img(String prompt, String modeName) {
        return R.ok(stableDiffusionClient.txt2Img(prompt, modeName));
    }

}
